import React, { PureComponent } from 'react';
import './flatterer.scss'
import Axios from 'axios';
// 引入接口
import { webSite } from '../../website'
// 引入点击复制到粘贴板的办法
import copy from 'copy-to-clipboard';
import { message } from 'antd';
export default class Phone extends PureComponent {
  constructor() {
    super()
    this.state = {
      text: ''
    }
  }
  componentDidMount () {
    Axios.create({
      baseURL: `${webSite}:3003`
    }).post("/getFlatterer").then(err => {
      if (err.data.code === 'F0001') {
        this.setState({
          text: err.data.text
        })
      }
    })
  }
  // 首页文字点击
  BtnCopy = () => {
    if (copy(this.state.text)) {
      message.success({ content: '舔狗日记复制成功', className: 'bulletChatMessage' });
    } else {
      message.error({ content: '您的设备不支持自动复制', className: 'bulletChatMessage' });
    }
  }
  render () {
    return (
      <div className='flatterer'>
        <img src={require('./img/fla.jpg')} alt="舔狗日记" />
        <div className='flatterer_body' onClick={this.BtnCopy}>
          {this.state.text}
        </div>
      </div>
    )
  }
}